package com.crpc.core.channelHandler;

import com.crpc.core.proxy.handler.CrpcRequestEncoder;
import com.crpc.core.proxy.handler.CrpcResponseDecoder;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;

/**
 * @author CLOUD
 * @version 1.0
 * @description:
 * @date 2023/9/10 14:19
 */
public class ConsumerChannelInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        socketChannel.pipeline()
                //netty自带的日志处理器
                .addLast(new LoggingHandler(LogLevel.INFO))
                //请求编码器
                .addLast(new CrpcRequestEncoder())
                //响应解码器
                .addLast(new CrpcResponseDecoder())
                .addLast(new MethodResponseHandler());


    }
}
